<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0 ,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<title>结算页面</title>
	<link href="AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet"
		type="text/css" />
	<link href="basic/css/demo.css" rel="stylesheet" type="text/css" />
	<link href="css/cartstyle.css" rel="stylesheet" type="text/css" />
	<link href="css/jsstyle.css" rel="stylesheet" type="text/css" />
	<style type="text/css">
.border {
	border: 1px solid red;
}
</style>
	<script type="text/javascript" src="js/address.js"></script>
	<script type="text/javascript">
		function test(obj) {
			$(obj).toggleClass("border");
			$(obj).siblings("li").removeClass('border');

			var address = $(obj).children("div.DefaultAddr").children(
					"span.buy--address-detail").children("span.province")
					.text();
			var shr = $(obj).children("div.user").children(
					"span.buy-address-detail").children("span.buy-user").text();
			var dh = $(obj).children("div.user").children(
					"span.buy-address-detail").children("span.buy-phone")
					.text();
			$("#address").html(address);
			$("#shr").html(shr);
			$("#dh").html(dh);
		}

		$(function() {
			$
					.ajax({
						url : "receipt.do?type=querylist",
						type : "POST",
						data : {}, //传递的参数
						dataType : "JSON",

						success : function(data) {//返回成功的操作
							$(".theme-popover").hide();
							var s = "";
							var receshow = $("#receiptshow");
							receshow.show();//显示收货地li
							receshow.empty();//清空li下所有的子元素(不包含本身)
							$.each(
										data.receiptlist,
											function(index, obj) {//第一个表示集合的下标，第二个参数表示这个集合的对象
												html = "<li class='user-addresslist' id='change' onclick='test(this)' <div class='address-left'><div class='user DefaultAddr'><span class='buy-address-detail'><span class='buy-user'>"
														+ obj.receipt_name
														+ "</span>"
														+ "<span class='buy-phone'>"
														+ obj.receipt_phone
														+ "</span>"
														+ "</span>"
														+ "</div>"
														+ "<div class='default-address DefaultAddr'><span class='buy-line-title buy-line-title-type'>收货地址：</span><span class='buy--address-detail'><span class='province'>"
														+ obj.receipt_addr
														+ "</span>"
														+ "</div>"
														+ "</div>"
														+ "<div class='address-right'><span class='am-icon-angle-right am-icon-lg'></span></div><div class='clear'></div><div class='new-addr-btn'><a href='javascript:void(0);' onclick='del(this,"
														+ obj.receipt_id
														+ ")'>删除</a></div></li>"
												s += html;
											});
							var result = s;
							$(result).appendTo(receshow);

						},
						error : function() {//请求失败要执行的操作
						}
					});

			$("#recesave").on("click",
					function() {
						var receipt_name = $("#receipt_name");
						var receipt_phone = $("#receipt_phone");
						var receipt_addr = $("#receipt_addr");

						if (receipt_name.val() == null
								|| receipt_name.val() == "") {
							alert("姓名不能为空！请重输");
							receipt_name.focus();
							return false;
						}
						if (receipt_phone.val() == null
								|| receipt_phone.val() == "") {
							alert("电话号码不能为空！请重输");
							receipt_phone.focus();
							return false;
						}
						if (receipt_addr.val() == null
								|| receipt_addr.val() == "") {
							alert("地址不能为空！请重输");
							receipt_addr.focus();
							return false;
						}
						$.ajax({
									url : "receipt.do?type=save",
									type : "POST",
									data : {
										receipt_name : receipt_name
												.val(),
										receipt_phone : receipt_phone
												.val(),
										receipt_addr : receipt_addr
												.val()
									}, //传递的参数
									dataType : "JSON",

									success : function(data) {//返回成功的操作
										$(".theme-popover").hide();
										var s = "";
										var receshow = $("#receiptshow");
										receshow.show();//显示收货地li
										receshow.empty();//清空li下所有的子元素(不包含本身)
									$.each(
										data.receiptlist,
										function(index,obj) {//第一个表示集合的下标，第二个参数表示这个集合的对象
											html = "<li class='user-addresslist'<div class='address-left'><div class='user DefaultAddr'><span class='buy-address-detail'><span class='buy-user'>"
													+ obj.receipt_name
													+ "</span>"
													+ "<span class='buy-phone'>"
													+ obj.receipt_phone
													+ "</span>"
													+ "</span>"
													+ "</div>"
													+ "<div class='default-address DefaultAddr'><span class='buy-line-title buy-line-title-type'>收货地址：</span><span class='buy--address-detail'><span class='province'>"
													+ obj.receipt_addr
													+ "</span>"
													+ "</div>"
													+ "</div>"
													+ "<div class='address-right'><span class='am-icon-angle-right am-icon-lg'></span></div><div class='clear'></div><div class='new-addr-btn'><a href='javascript:void(0);' onclick='del(this,"
													+ obj.receipt_id
													+ ");'>删除</a></div></li>"
											s += html;
										});
										var result = s;
										$(result).appendTo(receshow);
										/* $("#address").html(obj.receipt_addr); */

									},
									error : function() {//请求失败要执行的操作
									}
								});
							});
		});

		function del(obj, id) {
			var parent = $(obj).parent().parent();
			$.ajax({
				url : "receipt.do?type=delete",//返回的Url地址
				type : "POST",
				dataType : "JSON",//服务器返回的数据类型
				data : {
					receipt_id : id
				},
				success : function(data) {
					parent.remove();
				},
				error : function() {//请求失败要执行的操作
					alert("error");
				}

			});

		}
		function submitorder(){
		
			var oder_price  = $('#J_ActualFee').html();
			var receipt_addr = $("#address").html();
			var receipt_name = $("#shr").html();
			var receipt_phone = $("#dh").html();
				$.ajax({
				url : "address.do?type=add",//返回的Url地址
				type : "POST",
				dataType : "JSON",//服务器返回的数据类型
				data : {
					oder_price:oder_price,receipt_addr:receipt_addr,receipt_name:receipt_name,
					receipt_phone:receipt_phone
				},
					success : function(data) {//返回成功的操作
						alert(data.message);
						location.href="success.jsp";
					},
					error : function() {//请求失败要执行的操作
						alert("error");
					}
			});
			
		}
	</script>
</head>
<body>

	<!--顶部导航条 -->
	<div class="am-container header">
		<ul class="message-l">
			<div class="topMessage">
				<div class="menu-hd">
					<c:if test="${empty sessionScope.user_email}">
							<a href="<%=basePath %>Login.jsp" target="_top" class="h">亲，请登录</a>&nbsp;|
							<a href="Register.jsp" target="_top">免费注册</a>
						</c:if>	
						<c:if test="${!empty sessionScope.user_email}">
							<span>欢迎您${sessionScope.user_email}</span>&nbsp;&nbsp;
							<a href="<%=basePath %>loginOut.do" target="_parent">注销</a>
						</c:if>	
				</div>
			</div>
		</ul>
		<ul class="message-r">
			<div class="topMessage home">
				<div class="menu-hd">
					<a href="login.do?type=spQuery" target="_top" class="h">商城首页</a>
				</div>
			</div>
			<div class="topMessage my-shangcheng">
				<div class="menu-hd MyShangcheng">
					<a href="personal/personalInfo.jsp" target="_top"><i class="am-icon-user am-icon-fw"></i>个人中心</a>
				</div>
			</div>
			<div class="topMessage mini-cart">
				<div class="menu-hd">
					<a id="mc-menu-hd" href="#" target="_top"><i
						class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong
						id="J_MiniCartNum" class="h">0</strong>
					</a>
				</div>
			</div>
			<div class="topMessage favorite">
				<div class="menu-hd">
					<a href="#" target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span>
					</a>
				</div>
		</ul>
	</div>

	<!--悬浮搜索框-->

	<div class="nav white">
		<div class="logo">
			<img src="images/logo.png" />
		</div>
		<div class="logoBig">
			<li><img src="images/hualilogo.png" />
			</li>
		</div>

		<div class="search-bar pr">
			<a name="index_none_header_sysc" href="#"></a>
			<form>
				<input id="searchInput" name="index_none_header_sysc" type="text"
					placeholder="搜索" autocomplete="off"> <input
					id="ai-topsearch" class="submit am-btn" value="搜索" index="1"
					type="submit">
			</form>
		</div>
	</div>

	<div class="clear"></div>
	<div class="concent">
		<!--地址 -->
		<div class="paycont">
			<div class="address">
				<h3>确认收货地址</h3>
				<div class="control">
					<div class="tc-btn createAddr theme-login am-btn am-btn-danger">使用新地址</div>
				</div>
				<div class="clear"></div>
				<ul id="receiptshow">
					<div class="per-border"></div>


					<div class="per-border"></div>
					<!-- 循环地址开始 -->


					<!-- 循环地址结束 -->

				</ul>

				<div class="clear"></div>
			</div>
			<!--物流 -->
			<div class="logistics">
				<h3>选择物流方式</h3>
				<ul class="op_express_delivery_hot">
					<li data-value="yuantong" class="OP_LOG_BTN  "><i
						class="c-gap-right" style="background-position:0px -468px"></i>圆通<span></span>
					</li>
					<li data-value="shentong" class="OP_LOG_BTN  "><i
						class="c-gap-right" style="background-position:0px -1008px"></i>申通<span></span>
					</li>
					<li data-value="yunda" class="OP_LOG_BTN  "><i
						class="c-gap-right" style="background-position:0px -576px"></i>韵达<span></span>
					</li>
					<li data-value="zhongtong"
						class="OP_LOG_BTN op_express_delivery_hot_last "><i
						class="c-gap-right" style="background-position:0px -324px"></i>中通<span></span>
					</li>
					<li data-value="shunfeng"
						class="OP_LOG_BTN  op_express_delivery_hot_bottom"><i
						class="c-gap-right" style="background-position:0px -180px"></i>顺丰<span></span>
					</li>
				</ul>
			</div>
			<div class="clear"></div>

			<!--支付方式-->
			<div class="logistics">
				<h3>选择支付方式</h3>
				<ul class="pay-list">
					<li class="pay card"><img src="images/wangyin.jpg" />银联<span></span>
					</li>
					<li class="pay qq"><img src="images/weizhifu.jpg" />微信<span></span>
					</li>
					<li class="pay taobao"><img src="images/zhifubao.jpg" />支付宝<span></span>
					</li>
				</ul>
			</div>
			<div class="clear"></div>

			<!--订单 -->
			<div class="concent">
				<div id="payTable">
					<h3>确认订单信息</h3>
					<div class="cart-table-th">
						<div class="wp">

							<div class="th th-item">
								<div class="td-inner">商品信息</div>
							</div>
							<div class="th th-price">
								<div class="td-inner">单价</div>
							</div>
							<div class="th th-amount">
								<div class="td-inner">数量</div>
							</div>
							<div class="th th-sum">
								<div class="td-inner">金额</div>
							</div>
							<div class="th th-oplist">
								<div class="td-inner">配送方式</div>
							</div>

						</div>
					</div>
					<div class="clear"></div>

					<tr class="item-list">
						<div class="bundle  bundle-last">

							<div class="bundle-main">
								<ul class="item-content clearfix">
									<div class="pay-phone">
										<li class="td td-item">
											<div class="item-pic">
												<a href="#" class="J_MakePoint"> <img
													src="images/kouhong.jpg_80x80.jpg"
													class="itempic J_ItemImg">
												</a>
											</div>
											<div class="item-info">
												<div class="item-basic-info">
													<a href="#" class="item-title J_MakePoint"
														data-point="tbcart.8.11">美康粉黛醉美唇膏 持久保湿滋润防水不掉色</a>
												</div>
											</div></li>
										<li class="td td-info">
											<div class="item-props">
												<span class="sku-line">颜色：12#川南玛瑙</span> <span
													class="sku-line">包装：裸装</span>
											</div></li>
										<li class="td td-price">
											<div class="item-price price-promo-promo">
												<div class="price-content">
													<em class="J_Price price-now">39.00</em>
												</div>
											</div></li>
									</div>
									<li class="td td-amount">
										<div class="amount-wrapper ">
											<div class="item-amount ">
												<span class="phone-title">购买数量</span>
												<div class="sl">
													<input class="min am-btn" name="" type="button" value="-" />
													<input class="text_box" name="" type="text" value="3"
														style="width:30px;" /> <input class="add am-btn" name=""
														type="button" value="+" />
												</div>
											</div>
										</div></li>
									<li class="td td-sum">
										<div class="td-inner">
											<em tabindex="0" class="J_ItemSum number">117.00</em>
										</div></li>
									<li class="td td-oplist">
										<div class="td-inner">
											<span class="phone-title">配送方式</span>
											<div class="pay-logis">
												<b class="sys_item_freprice">包邮</b>
											</div>
										</div></li>

								</ul>
								<div class="clear"></div>

							</div>
					</tr>
					<div class="clear"></div>
				</div>

				<tr id="J_BundleList_s_1911116345_1" class="item-list">
					<div id="J_Bundle_s_1911116345_1_0" class="bundle  bundle-last">
						<div class="bundle-main">
							<ul class="item-content clearfix">
								<div class="pay-phone">
									<li class="td td-item">
										<div class="item-pic">
											<a href="#" class="J_MakePoint"> <img
												src="images/kouhong.jpg_80x80.jpg" class="itempic J_ItemImg">
											</a>
										</div>
										<div class="item-info">
											<div class="item-basic-info">
												<a href="#" target="_blank" title="美康粉黛醉美唇膏 持久保湿滋润防水不掉色"
													class="item-title J_MakePoint" data-point="tbcart.8.11">美康粉黛醉美唇膏
													持久保湿滋润防水不掉色</a>
											</div>
										</div></li>
									<li class="td td-info">
										<div class="item-props">
											<span class="sku-line">颜色：10#蜜橘色+17#樱花粉</span> <span
												class="sku-line">包装：两支手袋装（送彩带）</span>
										</div></li>
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">
												<em class="J_Price price-now">39.00</em>
											</div>
										</div></li>
								</div>

								<li class="td td-amount">
									<div class="amount-wrapper ">
										<div class="item-amount ">
											<span class="phone-title">购买数量</span>
											<div class="sl">
												<input class="min am-btn" name="" type="button" value="-" />
												<input class="text_box" name="" type="text" value="3"
													style="width:30px;" /> <input class="add am-btn" name=""
													type="button" value="+" />
											</div>
										</div>
									</div></li>
								<li class="td td-sum">
									<div class="td-inner">
										<em tabindex="0" class="J_ItemSum number">117.00</em>
									</div></li>
								<li class="td td-oplist">
									<div class="td-inner">
										<span class="phone-title">配送方式</span>
										<div class="pay-logis">包邮</div>
									</div></li>

							</ul>
							<div class="clear"></div>

						</div>
				</tr>
			</div>
			<div class="clear"></div>
			<div class="pay-total">

				<!--优惠券 -->
				<div class="buy-agio">
					<li class="td td-coupon"><span class="coupon-title">优惠券</span>
						<select data-am-selected>
							<option value="a">
								<div class="c-price">
									<strong>￥8</strong>
								</div>
								<div class="c-limit">【消费满95元可用】</div>
							</option>
							<option value="b" selected>
								<div class="c-price">
									<strong>￥3</strong>
								</div>
								<div class="c-limit">【无使用门槛】</div>
							</option>
					</select></li>

					<li class="td td-bonus"><span class="bonus-title">红包</span> <select
						data-am-selected>
							<option value="a">
								<div class="item-info">
									¥50.00<span>元</span>
								</div>
								<div class="item-remainderprice">
									<span>还剩</span>10.40<span>元</span>
								</div>
							</option>
							<option value="b" selected>
								<div class="item-info">
									¥50.00<span>元</span>
								</div>
								<div class="item-remainderprice">
									<span>还剩</span>50.00<span>元</span>
								</div>
							</option>
					</select></li>

				</div>
				<div class="clear"></div>
			</div>
			<!--含运费小计 -->
			<div class="buy-point-discharge ">
				<p class="price g_price ">
					合计（含运费） <span>¥</span><em class="pay-sum">244.00</em>
				</p>
			</div>

			<!--信息 -->
			
				<div class="order-go clearfix">
					<div class="pay-confirm clearfix">
						<div class="box">
							<div tabindex="0" id="holyshit267" class="realPay">
								<em class="t">实付款：</em> <span class="price g_price"
									name="order_price"> <span>¥</span> <em
									class="style-large-bold-red " id="J_ActualFee">244.00</em> </span>
							</div>

							<div id="holyshit268" class="pay-address">

								<p class="buy-footer-address">
									<span class="buy-line-title buy-line-title-type">寄送至：</span> <span
										class="province" id="address" name="receipt_addr"> </span>
								</p>
								<p class="buy-footer-address">
									<span class="buy-line-title">收货人：</span> <span
										class="buy-address-detail"> <span class="buy-user"
										id="shr" name="receipt_name"></span> <span class="buy-phone"
										id="dh" name="receipt_phone"></span> </span>
								</p>
								<!-- <c:if test="${!empty receiptlist}">
													<c:forEach items="${receiptlist}" var="receiptlist">
														<tr>
															<td><span>${receiptlist.receipt_name }</span></td>
															<td><span>${receiptlist.receipt_phone }</span></td>
															<td><span>${receiptlist.receipt_addr }</span></td>
														</tr>
													</c:forEach>
													
												</c:if> -->
							</div>
						</div>

						<div id="holyshit269" class="submitOrder">
							<div class="go-btn-wrap">
								
								<button type="submit" onclick="submitorder();" style="width: 80px;height:30px; background-color: #DD514A;color: white;">提交</button>
								<!-- <a  id="J_Go" href="success.html" class="btn-go" tabindex="0" title="点击此按钮，提交订单">提交订单</a> -->
							</div>
						</div>
						<div class="clear"></div>
					</div>
				</div>
			
		</div>

		<div class="clear"></div>
	</div>
	</div>
	<div class="footer">
		<div class="footer-hd">
			<p>
				<a href="#">恒望科技</a> <b>|</b> <a href="index.jsp">商城首页</a> <b>|</b> <a
					href="#">支付宝</a> <b>|</b> <a href="#">物流</a>
			</p>
		</div>
		<div class="footer-bd">
			<p>
				<a href="#">关于恒望</a> <a href="#">合作伙伴</a> <a href="#">联系我们</a> <a
					href="#">网站地图</a> <em>© 2015-2025 Hengwang.com 版权所有</em>
			</p>
		</div>
	</div>

	</div>


	<div class="theme-popover">

		<!--标题 -->
		<div class="am-cf am-padding">
			<div class="am-fl am-cf">
				<strong class="am-text-danger am-text-lg">新增地址</strong> / <small>Add
					address</small>
			</div>
		</div>
		<hr />

		<div class="am-u-md-12">
			<form class="am-form am-form-horizontal"
				action="<%=basePath%>receipt.do?type=save " method="post">

				<div class="am-form-group">
					<label for="user-name" class="am-form-label">收货人</label>
					<div class="am-form-content">
						<input type="text" id="receipt_name" placeholder="收货人"
							name="receipt_name">
					</div>
				</div>

				<div class="am-form-group">
					<label for="user-phone" class="am-form-label">手机号码</label>
					<div class="am-form-content">
						<input id="receipt_phone" placeholder="手机号必填" type="text"
							name="receipt_phone">
					</div>
				</div>



				<div class="am-form-group">
					<label for="user-intro" class="am-form-label">详细地址</label>
					<div class="am-form-content">
						<textarea class="" rows="3" id="receipt_addr" placeholder="输入详细地址"
							name="receipt_addr"></textarea>
						<small>100字以内写出你的详细地址...</small>
					</div>
				</div>

				<div class="am-form-group theme-poptit">
					<div class="am-u-sm-9 am-u-sm-push-3">
						<input class="am-btn am-btn-danger" type="button" value="保存"
							id="recesave"></input> <input class="am-btn am-btn-danger close"
							type="button" value="取消" id=""></input>
					</div>
				</div>
			</form>
		</div>

	</div>

	<div class="clear"></div>

</body>
<script>
	
</script>

</html>